<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of horzcat</title>
  <meta name="keywords" content="horzcat">
  <meta name="description" content="C=[A,B]">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="#">tt2</a> &gt; <a href="index.html">@tt_tensor</a> &gt; horzcat.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for tt2/@tt_tensor&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>horzcat
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>C=[A,B]</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [c]=horzcat(a,b) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">C=[A,B]
   C=HORZCAT(A,B) Horizontal cat of two block-row TT-tensors
   The result has r(d+1) = sum(r(d+1,A)+r(d+1,B)). The first ranks 
   should be equal for A and B


 TT-Toolbox 2.2, 2009-2012

This is TT Toolbox, written by Ivan Oseledets et al.
Institute of Numerical Mathematics, Moscow, Russia
webpage: http://spring.inm.ras.ru/osel

For all questions, bugs and suggestions please mail
ivan.oseledets@gmail.com
---------------------------</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>	Reshape of the TT-tensor</li><li><a href="tt_tensor.html" class="code" title="function t = tt_tensor(varargin)">tt_tensor</a>	TT-tensor constructor</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [c]=horzcat(a,b)</a>
0002 <span class="comment">%C=[A,B]</span>
0003 <span class="comment">%   C=HORZCAT(A,B) Horizontal cat of two block-row TT-tensors</span>
0004 <span class="comment">%   The result has r(d+1) = sum(r(d+1,A)+r(d+1,B)). The first ranks</span>
0005 <span class="comment">%   should be equal for A and B</span>
0006 <span class="comment">%</span>
0007 <span class="comment">%</span>
0008 <span class="comment">% TT-Toolbox 2.2, 2009-2012</span>
0009 <span class="comment">%</span>
0010 <span class="comment">%This is TT Toolbox, written by Ivan Oseledets et al.</span>
0011 <span class="comment">%Institute of Numerical Mathematics, Moscow, Russia</span>
0012 <span class="comment">%webpage: http://spring.inm.ras.ru/osel</span>
0013 <span class="comment">%</span>
0014 <span class="comment">%For all questions, bugs and suggestions please mail</span>
0015 <span class="comment">%ivan.oseledets@gmail.com</span>
0016 <span class="comment">%---------------------------</span>
0017 
0018 <span class="keyword">if</span> (isempty(b) )
0019   c=a;
0020   <span class="keyword">return</span>
0021 <span class="keyword">elseif</span> (isempty(a) )
0022   c=b;
0023   <span class="keyword">return</span>
0024 <span class="keyword">end</span>
0025 c=<a href="tt_tensor.html" class="code" title="function t = tt_tensor(varargin)">tt_tensor</a>;
0026 d=a.d;
0027 ra=a.r;
0028 n=a.n;
0029 psa=a.ps;
0030 cra=a.core;
0031 rb=b.r;
0032 crb=b.core;
0033 psb=b.ps;
0034 rc=ra+rb; 
0035 <span class="keyword">if</span> ( ra(1) == rb(1) )
0036 rc(1)=ra(1); <span class="comment">%The only modification</span>
0037 <span class="keyword">else</span>
0038   error(<span class="string">'Incorrect sizes in [A,B], please check'</span>);    
0039 <span class="keyword">end</span>
0040 psc=cumsum([1;n.*rc(1:d).*rc(2:d+1)]);
0041 crc=zeros(1,psc(d+1)-1);
0042 
0043 <span class="comment">%It seems: Ak</span>
0044 <span class="comment">%          Bk --- the first core</span>
0045 <span class="comment">%all others are blocks</span>
0046 
0047 <span class="keyword">for</span> i=1:d
0048   cr1=cra(psa(i):psa(i+1)-1);
0049   cr2=crb(psb(i):psb(i+1)-1);
0050   cr1=<a href="reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cr1,[ra(i),n(i),ra(i+1)]);
0051   cr2=<a href="reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(cr2,[rb(i),n(i),rb(i+1)]);
0052   cr3=zeros(rc(i),n(i),rc(i+1));
0053   cr3(1:ra(i),:,1:ra(i+1))=cr1;
0054   cr3(rc(i)-rb(i)+1:rc(i),:,rc(i+1)-rb(i+1)+1:rc(i+1))=cr2;
0055   crc(psc(i):psc(i+1)-1)=cr3(:);
0056 <span class="keyword">end</span>
0057 c.ps=psc;
0058 c.d=d;
0059 c.n=n;
0060 c.r=rc;
0061 c.core=crc;</pre></div>
<hr><address>Generated on Wed 08-Feb-2012 18:20:24 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>